﻿package extremefx {
	import extremefx.tools.StringUtils;	
	import extremefx.DateTimeKind;
	import extremefx.DateTime;
	import extremefx.TimeSpan;

	/**
	 * @author Marcelo Volmaro
	 */
	public final class TimeZone {

		private var _tzi:XML;
		private var _minYear:uint;
		private var _maxYear:uint;
		private var _name:String;
		private var _bias:int;
		private var _dbias:int;

		/**
    	 * Constructor
    	 * Initializes a new instance of the TimeZone class.
    	 * @param pIndex The timezone index to initialize the class.
    	 */

		function TimeZone(pIndex:int = 32){//GMT + 0
			_tzi = _timeZones.tz[pIndex];
			_name = _tzi.@n;

			if (_tzi.child("y").length() != 0){
				_minYear = _tzi.y[0].@n;
				_maxYear = _tzi.y[_tzi.child("y").length()-1].@n;

			} else {
				_minYear = 0;
				_maxYear = uint.MAX_VALUE;
			}

			_bias = _tzi.@b;
			_dbias = parseInt (_tzi.attribute("d")) || 0;
		}

		public function get name():String {
			return _name;
		}
		
				
		public static function sarasa(pDate:Date):void {
			var intTimezone_now:Number = pDate.getTimezoneOffset();
			var intFullYear_now:Number = pDate.getFullYear();
			
			var objDate_month1:Date	 = new Date("1 Jan " + intFullYear_now + " 00:00:00 " + _getTimezoneString(pDate));
			var objDate_month7:Date = new Date("1 Jul " + intFullYear_now + " 00:00:00 " + _getTimezoneString(pDate));
			var objDate_month12:Date = new Date("1 Dec " + intFullYear_now + " 00:00:00 " + _getTimezoneString(pDate));
		
			var intTimezone_month1:Number = objDate_month1.getTimezoneOffset();
			var intTimezone_month7:Number = objDate_month7.getTimezoneOffset();
			var blnDaylightSaving:Boolean = false;
			
			if (intTimezone_month1 != intTimezone_month7) {
				var intNSHemisphere:int = intTimezone_month1 > intTimezone_month7 ? 1 : 2;
		
				// Calculate boths dates at which clocks change
				var objDaylightStart:Date = intNSHemisphere == 1 ? _getDaylightSavingDay(objDate_month1, objDate_month7) : _getDaylightSavingDay(objDate_month7, objDate_month12);
				var objDaylightEnd:Date = intNSHemisphere == 1 ? _getDaylightSavingDay(objDate_month7, objDate_month12) : _getDaylightSavingDay(objDate_month1, objDate_month7);
		
				// Work out then if daylight saving is currently in force
				if (objDaylightStart.getTimezoneOffset() == intTimezone_now) {
					blnDaylightSaving = true;
				}
				
				// If start-date is after end date then swap displayed results around
				if (objDaylightStart > objDaylightEnd) {
					var temp:Date = objDaylightEnd;
					objDaylightEnd = objDaylightStart;
					objDaylightStart = temp;
				}
			}
		}
		
		private static function _getDaylightSavingDay(objIterationMin:Date, objIterationMax:Date):Date {
			var objTestDateOld:Date	= objIterationMin;
			var objTestDate:Date = objIterationMax;
		
			while(Math.abs(objTestDate.getTime() - objTestDateOld.getTime()) > 0) {
				objTestDateOld = objTestDate;
				objTestDate = new Date(objIterationMin.getTime() + Math.round((objIterationMax.getTime() - objIterationMin.getTime()) / 2));

				if (objTestDate.getTimezoneOffset() == objIterationMin.getTimezoneOffset()) {
					objIterationMin = objTestDate;
					
				} else {
					objIterationMax = objTestDate;
				}
			}
			
			return objTestDate;
		}
		
		private static function _getTimezoneString(pDate:Date):String {
			var intDateTZ:Number = pDate.getTimezoneOffset();
			var intDateTZ_hours:int = Math.floor(Math.abs(intDateTZ) / 60);
			var intDateTZ_minutes:int = Math.abs(intDateTZ_hours - (Math.abs(intDateTZ) / 60)) * 60;
			
			return "UTC" + 
			(intDateTZ > 0 ? "-" : "+") + 
			StringUtils.padLeft(intDateTZ_hours.toString(), 2, "0") +
			StringUtils.padLeft(intDateTZ_minutes.toString(), 2, "0"); 
		}

		//TODO: Need to research on this. While it is possible to get the timezone,
		//      I have no way to relate that value with the list of timezones here.
//		public static function get currentTimeZone():TimeZone {
//			return new TimeZone();
//		}

		/**
		 * Returns a list of all the availables timezones the class can handle
		 * @return an array with the names of the timezones.
		 */
		public static function listTimeZones():Vector.<String> {
			var tz:XMLList = _timeZones.tz;
			var a:Vector.<String> = new Vector.<String>();

			for each(var tzi:XML in tz){
				a.push(tzi.@n);
			}

			return a;
		}

		/**
		 * Gets a <code>DaylightTime</code> object with the specific daylight dates for the selected year.
		 * @param pY the year to get the daylight time dates
		 * @return the specific daylight dates for the selected year.
		 */
		public function getDaylightChanges(pY:Number):DaylightTime {
			return new DaylightTime(_getDST(pY, false), _getDST(pY, true));
		}

		/**
		 * Gets the time offset from UTC
		 * @param pD the <code>DateTime</code> from wich to get the offset
		 * @return a <code>TimeSpan</code> with the time offset (adjusted for daylight saving if neccessary).
		 */
		public function getUtcOffset(pD:DateTime):TimeSpan{
			return new TimeSpan(0, isDaylightSavingTime(pD) ? _bias : _bias+_dbias, 0);
		}


		/**
		 * Gets if daylight saving time applies to the supplied <code>DateTime</code> object.
		 * @param pNow the <code>DateTime</code> to check for daylight saving.
		 * @return true if the date is inside daylight saving, false if not.
		 */
		public function isDaylightSavingTime(pNow:DateTime):Boolean {
			if (!_minYear) return false;

			var standard:DateTime = _getDST(pNow.year, false);
			var daylight:DateTime = _getDST(pNow.year, true);

			if (pNow.kind == DateTimeKind.UTC) {
				standard.addMinutes(_bias);
				daylight.addMinutes(_bias);
			}

			var std:Number = standard.ticks;
			var dlt:Number = daylight.ticks;
			var now:Number = pNow.ticks;

			return (std < dlt) ? (now < std || dlt <= now) : (dlt <= now && now < std);
		}

		/**
		 * Converts from UTC time to local time.
		 * @param pNow an UTC date
		 * @return a new DateTime object
		 */
		public function toLocalTime(pNow:DateTime):DateTime {
			if (pNow._kind == DateTimeKind.LOCAL) return pNow;

			var d:DateTime = new DateTime(pNow);
			d.addMinutes(-_bias);
			d._kind = DateTimeKind.LOCAL;

			if (isDaylightSavingTime(pNow)) {
				d.addMinutes(-_dbias);
			}

			return d;
		}

		/**
		 * Converts from local time to UTC time.
		 */
		public function toUniversalTime(pNow:DateTime):DateTime {
			if (pNow._kind == DateTimeKind.UTC) return pNow;

			var d:DateTime = new DateTime(pNow);
			if (isDaylightSavingTime(d)) d.addMinutes(_dbias);
			d.addMinutes(_bias);
			d._kind = DateTimeKind.UTC;

			return d;
		}

		private function _getDST(pY:int, pGetDaylight:Boolean):DateTime {
			//no dst info
			if (!_minYear) return null;

			var hn:String, mnn:String, sn:String, mn:String, dn:String, dow:String, occ:String;

			if (pGetDaylight){
				mn = "dm";
				dn = "dd";
				hn = "dhh";
				mnn = "dmm";
				sn = "dss";
				dow = "ddow";
				occ = "do";

			} else {
				mn = "sm";
				dn = "sd";
				hn = "shh";
				mnn = "smm";
				sn = "sss";
				dow = "sdow";
				occ = "so";
			}

			var tzinfo:XML = _tzi;
			var tzY:XMLList = tzinfo.y;
			var tzi:XML;

			if (pY <= _minYear){
				tzi = tzY[0];

			} else if (pY >= _maxYear){
				tzi = tzY[tzY.length()-1];

			} else {
				tzi = tzY.(@n == pY)[0];
			}

			var m:int = parseInt (tzi.attribute(mn));
			var hh:int = parseInt (tzi.attribute(hn)) || 0;
			var mm:int = parseInt (tzi.attribute(mnn)) || 0;
			var ss:int = parseInt (tzi.attribute(sn)) || 0;

			if (tzi.hasOwnProperty("@sdow")){//first of, last of...
				return new DateTime(pY, m, _calcStartEnd(pY, m, parseInt(tzi.attribute(dow)), parseInt(tzi.attribute(occ))), hh, mm, ss);

			} else {//exact date
				return new DateTime(pY, m || 1, parseInt(tzi.attribute(dn)) || 1, hh, mm, ss);
			}
		}

		/**
		 * @param y:int Year
		 * @param m:int Month (1 - 12)
		 * @param n:int Day of the week (0 for a Sunday, 1 for a Monday, 2 for a Tuesday, etc)
		 * @param w:int Occurence (1:first, 2:second, 3:third, 4:fourth, -1:last)
		 * @return real day of the month where the DST starts/ends
		 */

		private function _calcStartEnd(y:int, m:int, n:int, w:int):int{
			if (w < 0){
				var nd:Number = (new Date(y, m+1, 0)).getDate();
				var diff:Number = (_getDayOfWeek(y, m, nd) - n) % 7;
				if (diff < 0) diff += 7;
				return nd-diff;
			}

			var nq:int = 7 * w - 6 + (n - _getDayOfWeek(y, m, 1)) % 7;
			if (nq < 1) nq += 7;

			return nq;
		}

		/**
		 * @param y:int Year
		 * @param m:int Month (1 - 12)
		 * @param d:int Day (1 - 31)
		 * @return 0 for a Sunday, 1 for a Monday, 2 for a Tuesday, etc.
		 */

		private function _getDayOfWeek(y:int, m:int, d:int):int{
			var a:int = int((14 - m) / 12);
			y -= a;
			m += 12 * a - 2;
			var r:int =  (d + y + int(y/4) - int(y/100) + int(y/400) + int((31*m)/12))%7;
			if (r < 0) {
				return 7+r;

			} else {
				return r;
			}
		}

		private static var _timeZones:XML = <timezones>
	<tz n="(GMT-12:00) International Date Line West" b="720"/>
	<tz n="(GMT-11:00) Midway Island, Samoa" b="660"/>
	<tz n="(GMT-10:00) Hawaii" b="600"/>
	<tz n="(GMT-09:00) Alaska" b="540" d="-60">
		<y n="2006" so="-1" sdow="0" sm="10" do="1" ddow="0" dm="4" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2007" so="1" sdow="0" sm="11" do="2" ddow="0" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT-08:00) Pacific Time (US &amp; Canada)" b="480" d="-60">
		<y n="2006" so="-1" sdow="0" sm="10" do="1" ddow="0" dm="4" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2007" so="1" sdow="0" sm="11" do="2" ddow="0" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT-08:00) Tijuana, Baja California" b="480" d="-60">
		<y so="-1" sdow="0" sm="10" do="1" ddow="0" dm="4" shh="2" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT-07:00) Arizona" b="420"/>
	<tz n="(GMT-07:00) Chihuahua, La Paz, Mazatlan - New" b="420" d="-60">
		<y so="-1" sdow="0" sm="10" do="1" ddow="0" dm="4" shh="2" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT-07:00) Chihuahua, La Paz, Mazatlan - Old" b="420" d="-60">
		<y so="-1" sdow="0" sm="10" do="1" ddow="0" dm="4" shh="2" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT-07:00) Mountain Time (US &amp; Canada)" b="420" d="-60">
		<y n="2006" so="-1" sdow="0" sm="10" do="1" ddow="0" dm="4" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2007" so="1" sdow="0" sm="11" do="2" ddow="0" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT-06:00) Central America" b="360"/>
	<tz n="(GMT-06:00) Central Time (US &amp; Canada)" b="360" d="-60">
		<y n="2006" so="-1" sdow="0" sm="10" do="1" ddow="0" dm="4" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2007" so="1" sdow="0" sm="11" do="2" ddow="0" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT-06:00) Guadalajara, Mexico City, Monterrey - New" b="360" d="-60">
		<y so="-1" sdow="0" sm="10" do="1" ddow="0" dm="4" shh="2" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT-06:00) Guadalajara, Mexico City, Monterrey - Old" b="360" d="-60">
		<y so="-1" sdow="0" sm="10" do="1" ddow="0" dm="4" shh="2" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT-06:00) Saskatchewan" b="360"/>
	<tz n="(GMT-05:00) Bogota, Lima, Quito, Rio Branco" b="300"/>
	<tz n="(GMT-05:00) Eastern Time (US &amp; Canada)" b="300" d="-60">
		<y n="2006" so="-1" sdow="0" sm="10" do="1" ddow="0" dm="4" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2007" so="1" sdow="0" sm="11" do="2" ddow="0" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT-05:00) Indiana (East)" b="300"/>
	<tz n="(GMT-04:30) Caracas" b="270"/>
	<tz n="(GMT-04:00) Atlantic Time (Canada)" b="240" d="-60">
		<y n="2006" so="-1" sdow="0" sm="10" do="1" ddow="0" dm="4" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2007" so="1" sdow="0" sm="11" do="2" ddow="0" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT-04:00) La Paz" b="240"/>
	<tz n="(GMT-04:00) Manaus" b="240" d="-60">
		<y n="2006" so="2" sdow="0" sm="2" do="1" ddow="0" dm="11" shh="2" dhh="0" dmm="0" dss="0"/>
		<y n="2007" so="-1" sdow="0" sm="2" do="2" ddow="0" dm="10" dhh="0" dmm="0" dss="0"/>
		<y n="2008" so="3" sdow="0" sm="2" do="3" ddow="6" dm="10" dhh="23" dmm="59" dss="59"/>
		<y n="2009" so="2" sdow="6" sm="2" do="3" ddow="6" dm="10" shh="23" smm="59" sss="59" dhh="23" dmm="59" dss="59"/>
	</tz>
	<tz n="(GMT-04:00) Santiago" b="240" d="-60">
		<y n="2008" so="-1" sdow="6" sm="3" do="2" ddow="6" dm="10" shh="23" smm="59" sss="59" dhh="23" dmm="59" dss="59"/>
		<y n="2009" so="2" sdow="6" sm="3" do="2" ddow="6" dm="10" shh="23" smm="59" sss="59" dhh="23" dmm="59" dss="59"/>
	</tz>
	<tz n="(GMT-03:30) Newfoundland" b="210" d="-60">
		<y n="2006" so="-1" sdow="0" sm="10" do="1" ddow="0" dm="4" smm="1" dhh="0" dmm="1" dss="0"/>
		<y n="2007" so="1" sdow="0" sm="11" do="2" ddow="0" dm="3" smm="1" dhh="0" dmm="1" dss="0"/>
	</tz>
	<tz n="(GMT-03:00) Brasilia" b="180" d="-60">
		<y n="2006" so="2" sdow="0" sm="2" do="1" ddow="0" dm="11" shh="2" dhh="0" dmm="0" dss="0"/>
		<y n="2007" so="-1" sdow="0" sm="2" do="2" ddow="0" dm="10" dhh="0" dmm="0" dss="0"/>
		<y n="2008" so="3" sdow="0" sm="2" do="3" ddow="6" dm="10" dhh="23" dmm="59" dss="59"/>
		<y n="2009" so="2" sdow="6" sm="2" do="3" ddow="6" dm="10" shh="23" smm="59" sss="59" dhh="23" dmm="59" dss="59"/>
	</tz>
	<tz n="(GMT-03:00) Buenos Aires" b="180" d="-60">
		<y n="2006"/>
		<y n="2007" so="1" sdow="1" sm="1" do="-1" ddow="0" dm="12" dhh="0" dmm="0" dss="0"/>
		<y n="2008" so="3" sdow="0" sm="3" do="3" ddow="6" dm="10" dhh="23" dmm="59" dss="59"/>
		<y n="2009" so="2" sdow="6" sm="3" do="3" ddow="6" dm="10" shh="23" smm="59" sss="59" dhh="23" dmm="59" dss="59"/>
	</tz>
	<tz n="(GMT-03:00) Georgetown" b="180"/>
	<tz n="(GMT-03:00) Greenland" b="180" d="-60">
		<y so="-1" sdow="0" sm="10" do="1" ddow="0" dm="4" shh="2" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT-03:00) Montevideo" b="180" d="-60">
		<y so="2" sdow="0" sm="3" do="1" ddow="0" dm="10" shh="2" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT-02:00) Mid-Atlantic" b="120" d="-60">
		<y so="-1" sdow="0" sm="9" do="-1" ddow="0" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT-01:00) Azores" b="60" d="-60">
		<y so="-1" sdow="0" sm="10" do="-1" ddow="0" dm="3" shh="3" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT-01:00) Cape Verde Is." b="60"/>
	<tz n="(GMT) Casablanca" b="0" d="-60">
		<y n="2008" so="-1" sdow="0" sm="8" do="-1" ddow="6" dm="5" shh="23" smm="59" sss="59" dhh="23" dmm="59" dss="59"/>
		<y n="2009"/>
	</tz>
	<tz n="(GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London" b="0" d="-60">
		<y so="-1" sdow="0" sm="10" do="-1" ddow="0" dm="3" shh="2" dhh="1" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT) Monrovia, Reykjavik" b="0"/>
	<tz n="(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna" b="-60" d="-60">
		<y so="-1" sdow="0" sm="10" do="-1" ddow="0" dm="3" shh="3" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague" b="-60" d="-60">
		<y so="-1" sdow="0" sm="10" do="-1" ddow="0" dm="3" shh="3" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+01:00) Brussels, Copenhagen, Madrid, Paris" b="-60" d="-60">
		<y so="-1" sdow="0" sm="10" do="-1" ddow="0" dm="3" shh="3" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+01:00) Sarajevo, Skopje, Warsaw, Zagreb" b="-60" d="-60">
		<y so="-1" sdow="0" sm="10" do="-1" ddow="0" dm="3" shh="3" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+01:00) West Central Africa" b="-60"/>
	<tz n="(GMT+02:00) Amman" b="-120" d="-60">
		<y n="2006" so="-1" sdow="5" sm="9" do="-1" ddow="4" dm="3" shh="1" dhh="0" dmm="0" dss="0"/>
		<y n="2007" so="-1" sdow="5" sm="10" do="-1" ddow="4" dm="3" shh="1" dhh="23" dmm="59" dss="59"/>
	</tz>
	<tz n="(GMT+02:00) Athens, Bucharest, Istanbul" b="-120" d="-60">
		<y so="-1" sdow="0" sm="10" do="-1" ddow="0" dm="3" shh="4" dhh="3" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+02:00) Beirut" b="-120" d="-60">
		<y so="-1" sdow="6" sm="10" do="-1" ddow="0" dm="3" shh="23" smm="59" sss="59" dhh="0" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+02:00) Cairo" b="-120" d="-60">
		<y n="2005" so="-1" sdow="4" sm="9" do="-1" ddow="5" dm="4" shh="23" smm="59" sss="59" dhh="0" dmm="0" dss="0"/>
		<y n="2006" so="3" sdow="4" sm="9" do="-1" ddow="5" dm="4" shh="23" smm="59" sss="59" dhh="0" dmm="0" dss="0"/>
		<y n="2007" so="1" sdow="4" sm="9" do="-1" ddow="4" dm="4" shh="23" smm="59" sss="59" dhh="23" dmm="59" dss="59"/>
		<y n="2008" so="-1" sdow="4" sm="8" do="-1" ddow="4" dm="4" shh="23" smm="59" sss="59" dhh="23" dmm="59" dss="59"/>
		<y n="2009" so="-1" sdow="4" sm="9" do="4" ddow="4" dm="4" shh="23" smm="59" sss="59" dhh="23" dmm="59" dss="59"/>
		<y n="2010" so="-1" sdow="4" sm="9" do="-1" ddow="4" dm="4" shh="23" smm="59" sss="59" dhh="23" dmm="59" dss="59"/>
		<y n="2011" so="-1" sdow="4" sm="9" do="4" ddow="4" dm="4" shh="23" smm="59" sss="59" dhh="23" dmm="59" dss="59"/>
	</tz>
	<tz n="(GMT+02:00) Harare, Pretoria" b="-120"/>
	<tz n="(GMT+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius" b="-120" d="-60">
		<y so="-1" sdow="0" sm="10" do="-1" ddow="0" dm="3" shh="4" dhh="3" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+02:00) Jerusalem" b="-120" d="-60">
		<y n="2004"/>
		<y n="2005" so="2" sdow="0" sm="10" do="1" ddow="5" dm="4" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2006" so="1" sdow="0" sm="10" do="-1" ddow="5" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2007" so="3" sdow="0" sm="9" do="-1" ddow="5" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2008" so="1" sdow="0" sm="10" do="-1" ddow="5" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2009" so="-1" sdow="0" sm="9" do="-1" ddow="5" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2010" so="2" sdow="0" sm="9" do="-1" ddow="5" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2011" so="1" sdow="0" sm="10" do="1" ddow="5" dm="4" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2012" so="4" sdow="0" sm="9" do="-1" ddow="5" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2013" so="2" sdow="0" sm="9" do="-1" ddow="5" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2014" so="4" sdow="0" sm="9" do="-1" ddow="5" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2015" so="3" sdow="0" sm="9" do="-1" ddow="5" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2016" so="2" sdow="0" sm="10" do="1" ddow="5" dm="4" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2017" so="4" sdow="0" sm="9" do="-1" ddow="5" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2018" so="3" sdow="0" sm="9" do="-1" ddow="5" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2019" so="1" sdow="0" sm="10" do="-1" ddow="5" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2020" so="4" sdow="0" sm="9" do="-1" ddow="5" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2021" so="2" sdow="0" sm="9" do="-1" ddow="5" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2022" so="1" sdow="0" sm="10" do="1" ddow="5" dm="4" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2023"/>
		<y n="2024" so="-1" sdow="0" sm="9" do="-1" ddow="5" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+02:00) Minsk" b="-120" d="-60">
		<y so="-1" sdow="0" sm="10" do="-1" ddow="0" dm="3" shh="3" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+02:00) Windhoek" b="-120" d="60">
		<y so="1" sdow="0" sm="9" do="1" ddow="0" dm="4" shh="2" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+03:00) Baghdad" b="-180" d="-60">
		<y n="2006" so="1" sdow="0" sm="10" do="1" ddow="0" dm="4" shh="4" dhh="3" dmm="0" dss="0"/>
		<y n="2007" so="1" sdow="1" sm="10" do="1" ddow="0" dm="4" shh="4" dhh="3" dmm="0" dss="0"/>
		<y n="2008"/>
	</tz>
	<tz n="(GMT+03:00) Kuwait, Riyadh" b="-180"/>
	<tz n="(GMT+03:00) Moscow, St. Petersburg, Volgograd" b="-180" d="-60">
		<y so="-1" sdow="0" sm="10" do="-1" ddow="0" dm="3" shh="3" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+03:00) Nairobi" b="-180"/>
	<tz n="(GMT+03:00) Tbilisi" b="-180"/>
	<tz n="(GMT+03:30) Tehran" b="-210" d="-60">
		<y n="2005" so="4" sdow="2" sm="9" do="1" ddow="0" dm="3" shh="2" dhh="2" dmm="0" dss="0"/>
		<y n="2006"/>
		<y n="2008" so="3" sdow="6" sm="9" do="3" ddow="4" dm="3" shh="23" smm="59" sss="59" dhh="23" dmm="59" dss="59"/>
		<y n="2009" so="3" sdow="1" sm="9" do="3" ddow="6" dm="3" shh="23" smm="59" sss="59" dhh="23" dmm="59" dss="59"/>
	</tz>
	<tz n="(GMT+04:00) Abu Dhabi, Muscat" b="-240"/>
	<tz n="(GMT+04:00) Baku" b="-240" d="-60">
		<y so="-1" sdow="0" sm="10" do="-1" ddow="0" dm="3" shh="5" dhh="4" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+04:00) Caucasus Standard Time" b="-240"/>
	<tz n="(GMT+04:00) Port Louis" b="-240" d="-60">
		<y n="2007"/>
		<y n="2008" so="1" sdow="2" sm="1" do="-1" ddow="0" dm="10" dhh="2" dmm="0" dss="0"/>
		<y n="2009" so="-1" sdow="0" sm="3" do="-1" ddow="0" dm="10" shh="2" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+04:00) Yerevan" b="-240" d="-60">
		<y so="-1" sdow="0" sm="10" do="-1" ddow="0" dm="3" shh="3" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+04:30) Kabul" b="-270"/>
	<tz n="(GMT+05:00) Ekaterinburg" b="-300" d="-60">
		<y so="-1" sdow="0" sm="10" do="-1" ddow="0" dm="3" shh="3" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+05:00) Islamabad, Karachi" b="-300" d="-60">
		<y n="2008" so="-1" sdow="5" sm="10" do="-1" ddow="6" dm="5" shh="23" smm="59" sss="59" dhh="23" dmm="59" dss="59"/>
		<y n="2009"/>
	</tz>
	<tz n="(GMT+05:00) Tashkent" b="-300"/>
	<tz n="(GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi" b="-330"/>
	<tz n="(GMT+05:30) Sri Jayawardenepura" b="-330"/>
	<tz n="(GMT+05:45) Kathmandu" b="-345"/>
	<tz n="(GMT+06:00) Almaty, Novosibirsk" b="-360" d="-60">
		<y so="-1" sdow="0" sm="10" do="-1" ddow="0" dm="3" shh="3" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+06:00) Astana, Dhaka" b="-360"/>
	<tz n="(GMT+06:30) Yangon (Rangoon)" b="-390"/>
	<tz n="(GMT+07:00) Bangkok, Hanoi, Jakarta" b="-420"/>
	<tz n="(GMT+07:00) Krasnoyarsk" b="-420" d="-60">
		<y so="-1" sdow="0" sm="10" do="-1" ddow="0" dm="3" shh="3" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+08:00) Beijing, Chongqing, Hong Kong, Urumqi" b="-480"/>
	<tz n="(GMT+08:00) Irkutsk, Ulaan Bataar" b="-480" d="-60">
		<y so="-1" sdow="0" sm="10" do="-1" ddow="0" dm="3" shh="3" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+08:00) Kuala Lumpur, Singapore" b="-480"/>
	<tz n="(GMT+08:00) Perth" b="-480" d="-60">
		<y n="2005"/>
		<y n="2006" sd="1" sm="1" dd="1" dm="12" dhh="2" dmm="0" dss="0"/>
		<y n="2007" so="-1" sdow="0" sm="3" do="-1" ddow="0" dm="10" shh="3" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+08:00) Taipei" b="-480"/>
	<tz n="(GMT+09:00) Osaka, Sapporo, Tokyo" b="-540"/>
	<tz n="(GMT+09:00) Seoul" b="-540"/>
	<tz n="(GMT+09:00) Yakutsk" b="-540" d="-60">
		<y so="-1" sdow="0" sm="10" do="-1" ddow="0" dm="3" shh="3" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+09:30) Adelaide" b="-570" d="-60">
		<y n="2007" so="-1" sdow="0" sm="3" do="-1" ddow="0" dm="10" shh="3" dhh="2" dmm="0" dss="0"/>
		<y n="2008" so="1" sdow="0" sm="4" do="1" ddow="0" dm="10" shh="3" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+09:30) Darwin" b="-570"/>
	<tz n="(GMT+10:00) Brisbane" b="-600"/>
	<tz n="(GMT+10:00) Canberra, Melbourne, Sydney" b="-600" d="-60">
		<y n="2007" so="-1" sdow="0" sm="3" do="-1" ddow="0" dm="10" shh="3" dhh="2" dmm="0" dss="0"/>
		<y n="2008" so="1" sdow="0" sm="4" do="1" ddow="0" dm="10" shh="3" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+10:00) Guam, Port Moresby" b="-600"/>
	<tz n="(GMT+10:00) Hobart" b="-600" d="-60">
		<y n="2007" so="-1" sdow="0" sm="3" do="1" ddow="0" dm="10" shh="3" dhh="2" dmm="0" dss="0"/>
		<y n="2008" so="1" sdow="0" sm="4" do="1" ddow="0" dm="10" shh="3" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+10:00) Vladivostok" b="-600" d="-60">
		<y so="-1" sdow="0" sm="10" do="-1" ddow="0" dm="3" shh="3" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+11:00) Magadan, Solomon Is., New Caledonia" b="-660"/>
	<tz n="(GMT+12:00) Auckland, Wellington" b="-720" d="-60">
		<y n="2006" so="3" sdow="0" sm="3" do="1" ddow="0" dm="10" shh="3" dhh="2" dmm="0" dss="0"/>
		<y n="2007" so="3" sdow="0" sm="3" do="-1" ddow="0" dm="9" shh="3" dhh="2" dmm="0" dss="0"/>
		<y n="2008" so="1" sdow="0" sm="4" do="-1" ddow="0" dm="9" shh="3" dhh="2" dmm="0" dss="0"/>
	</tz>
	<tz n="(GMT+12:00) Fiji, Kamchatka, Marshall Is." b="-720"/>
	<tz n="(GMT+13:00) Nuku'alofa" b="-780"/>
</timezones>;

	}
}
